package com.jeeplus.test.jlnu.timeConfigManage.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.test.jlnu.timeConfigManage.domain.TimeConfig;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
public interface TimeConfigMapper {

    @Select("SELECT principal FROM time_config " +
            "WHERE start_date <= #{date} AND end_date >= #{date} " +
            "ORDER BY start_date DESC LIMIT 1")
    //根据日期查询
    String findPrincipalByDate(@Param("date") Date date);


    //新增时间配置
    int saveOrUpdate(TimeConfig timeConfig);

    //根据日期查询数据
    List<TimeConfig> listByDate(Date date);

    //分页查询
    Page<TimeConfig> getTimeConfigPage(TimeConfig timeConfig, Page<TimeConfig> page);

    //删除
    boolean deleteById(Integer id);

}
